﻿@using Lavka.Core
@model IEnumerable<Lavka.Models.Products>

@if (Request.IsAuthenticated)
 {
     <p>
         @Html.ActionLink("Создать товар", "Create")
     </p>
 }
 
@Html.Partial("ViewSelector", DisplayType.List)

<input type="hidden" id="hCategoryId" value="@ViewBag.categoryId"/>

<div class="roundedTable">
<table id="productsTable" class="productsTable">
<tr>
    @if (Request.IsAuthenticated)
    {        
        <th>
            Действия
        </th>
        <th class="products-table-div"></th>
    }
        <th>
            Фото
        </th>
        <th class="products-table-div"></th>
        <th class="products-name">
            @if (ViewBag.SortFilter == SortFilter.Name)
            {
                if (ViewBag.SortAscending)
                {
                    <img src="@Url.Content("~/Content/images/sort-up.png")" style="vertical-align: middle;" />
                }
                else
                {
                   <img src="@Url.Content("~/Content/images/sort-down.png")" style="vertical-align: middle;" /> 
                }
            }
            @Html.ActionLink("Наименование", "Sort", new { filter = SortFilter.Name })
        </th>
        <th class="products-table-div"></th>
        <th>
            Артикул
        </th>
        <th class="products-table-div"></th>
        <th>
            @if (ViewBag.SortFilter == SortFilter.Brand)
            {
                if (ViewBag.SortAscending)
                {
                    <img src="@Url.Content("~/Content/images/sort-up.png")" style="vertical-align: middle;" />
                }
                else
                {
                   <img src="@Url.Content("~/Content/images/sort-down.png")" style="vertical-align: middle;" /> 
                }
            }
            @Html.ActionLink("Производитель", "Sort", new { filter = SortFilter.Brand })
        </th>
        <th class="products-table-div"></th>
        <th>
            @if (ViewBag.SortFilter == SortFilter.Price)
            {
                if (ViewBag.SortAscending)
                {
                    <img src="@Url.Content("~/Content/images/sort-up.png")" style="vertical-align: middle;" />
                }
                else
                {
                   <img src="@Url.Content("~/Content/images/sort-down.png")" style="vertical-align: middle;" /> 
                }
            }
            @Html.ActionLink("Цена", "Sort", new { filter = SortFilter.Price })
        </th>
        <th class="products-table-div"></th>
        <th>Корзина</th>
    </tr>

    @Html.Partial("ProductsList", Model)

</table>
</div>

<script type="text/javascript">
    $(document).ready(function (){
        UpdateProductsList();
    });
</script>